namespace RFIDOdata.Models
{
    using System;
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Linq;

    public partial class Model2 : DbContext
    {
        public Model2()
            : base("name=Model2")
        {
        }

        public virtual DbSet<Container> Containers { get; set; }
        public virtual DbSet<ContainerBox> ContainerBoxes { get; set; }
        public virtual DbSet<Product> Products { get; set; }
        public virtual DbSet<ProductMove> ProductMoves { get; set; }
        public virtual DbSet<sysdiagram> sysdiagrams { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Container>()
                .Property(e => e.ContainerDept)
                .IsUnicode(false);

            modelBuilder.Entity<Product>()
                .Property(e => e.ProductName)
                .IsUnicode(false);

            modelBuilder.Entity<Product>()
                .HasMany(e => e.ContainerBoxes)
                .WithOptional(e => e.Product)
                .HasForeignKey(e => e.ProductNo);

            modelBuilder.Entity<Product>()
                .HasMany(e => e.ContainerBoxes1)
                .WithOptional(e => e.Product1)
                .HasForeignKey(e => e.ProductNo);

            modelBuilder.Entity<ProductMove>()
                .Property(e => e.ProductMoveType)
                .IsUnicode(false);

            modelBuilder.Entity<ProductMove>()
                .Property(e => e.ProductMoveState)
                .IsUnicode(false);
        }
    }
}
